100 C Programs For Engineering 1st year Students For All Branches
Page 1
1. Program to print text
# include <stdio.h>
# include <conio.h>
main()
{
clrscr();
printf(“HELLO WELCOME TO VIDYA RTHI COMPUTERS”);
printf(“Hanamkonda Warangal phone : 0870-2574900, 9849103344”);
getch();
}
2. Program To Read Two Numbers And Print The Sum Of Given Two Numbers.
# include <stdio.h>
# include <conio.h>
main()
{
int a,b, sum;
clrscr ();
printf (“ENTER VALUE FOR A ; “);
scanf (“%d”,&a);
printf(“ENTER VALUE FOR B ;”);
scanf(“%d”,&b);
sum=a+b;
printf(“Sum Of Given Two Numbers are %d”, sum);
getch();
}
3. Program To Accept Student Roll No, Marks in 3 Subjects and Calculate Total, Average and Print it.
# include <stdio.h>
# include <conio.h>
main()
{
int r,b,c,d, tot, avg;
clrscr();
printf (“ENTER STUDENT RNO ; “);
scanf (“%d”,&r);
printf(“ENTER FIRST SUBJECT MARKS ;”);
scanf(“%d”,&b);
printf(“ENTER SECOND SUBJECT MARKS;”);
scanf(“%d”,&c);
printf(“ENTER THIRD SUBJECT MARKS ;”);
scanf(“%d”,&d);
tot=b+c+d;
avg=tot/3;
printf(“\n\n\t\t VIDYARTHI COMPUTERS – HANAMAKONDA \n\n”);
printf(“\t STUDENT RNO ; %d “,r);
printf(“\t FIRST SUBJECT MARKS ;%d “,b);
printf(“\t SECOND SUBJECT MARKS ;%d “,C);
printf(“\t THIRD SUBJECT MARKS ;%d “,d);
printf(“\t AVERAGE MARKS ; %d”, avg);
getch();
}
4. Program To Read Three Numbers And Print The Biggest Of Given Three Numbers
# include <stdio.h>
# include <conio.h>
main( )
{
int a,b,c,big=0;
clrscr( );
printf(“ENTER VALUE FOR A:”);
scanf(“%d”,&a);
printf(“ENTER VALUE FOR B:”);
scanf(“%d”,&b);
print(“ENTER VALUE FOR C:”);
scanf(“%d”,&c);
if (a>big)
big=a ;
if(b>big)
big=b;
if (c>big)
big=c;
printf (“BIGGEST OF ABOVE GIVEN THREE NUMBER IS %d”,big)
getch( );
}
5. Program To Read A Number And Find Whether The Given Number Is Even Or Odd.
# include <stdio.h>
# include <conio.h>
main()
{
int n,r;
clrscr();
printf(“ENTER A NUMBER ;”);
scanf(“%d”, &n);
r=n%2;
if(r= = 0)
printf(“the above given number is even number”);
else
printf(“the above given number is odd number”);
getch();
}
6. Program to accept a year and check whether the given year IS leap year or not.
# include <stdio.h>
# include <conio.h>
main( )
{
int y;
clrscr( );
printf(“enter a year:”);
scanf(“%d”,&y);
if(y%4==0& &y%100!=0|| y%400==0)
printf(“the above given year IS a leap year”);
else
printf(“the above given year IS not a leap year”);
getch();
}
7. Individual Digits
# include <stdio.h>
# include <conio.h>
main( )
{
int a,b,c,d;
clrscr( );
printf ( “ Enter a two digit number :”);
scanf (“ %d”, &a);
b=a/10;
c=a%10;
d=b+c;
printf (“sum of individual digits of given numbers id %”, d);
getch( );
}
8. Program to accept a three digit number and print the sum of individual digits.
# include <stdio.h>
# include <conio.h>
main( )
{
int a,b,c,n, sum;
clrscr( );
printf (“ Enter a Three Digit Number:“);
scanf (“%d”,&n);
a=n/100;
b=( (n%100)/10);
c=n%10;
sum=a+b+c;
printf (“ Sum of Individual Digits of Given Numbers is %d”, Sum);
getch( );
}
9. Program to accept a number and check the given number is Armstrong or not.
# include <stdio.h>
# include <conio.h>
main( )
{
int n, a, b, c, d;
clrscr( );
printf (“ Enter a Three Digit Number: “);
scanf (“%d”, &n);
a=n/100;
b=((n/10)%10);
c=n%10;
d=a*a*a*+b*b*b +c*c*c;
if (n= =d)
printf (“The Given Number is Armstrong number”);
else
printf (“The Given Number is Not Armstrong number”);
getch( );
}
10. Program to print ODD numbers from 1 to 10
# include <stdio.h>
# include <conio.h>
main( )
{
int i;
clrscr( );
for (i=1; i<=10; i+=2)
printf(“%d\n”,i);
getch( );
}
0 comments:
Post a Comment