0% found this document useful (0 votes)
12 views4 pages

Chap 5 All Program

The document contains a series of programming exercises with C code solutions, including tasks such as printing even numbers, generating multiplication tables, calculating averages, and printing factorials. Each exercise is presented with its corresponding code snippet and intended functionality. The exercises cover basic programming concepts such as loops, conditionals, and input/output operations.

Uploaded by

Adil Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Chap 5 All Program

The document contains a series of programming exercises with C code solutions, including tasks such as printing even numbers, generating multiplication tables, calculating averages, and printing factorials. Each exercise is presented with its corresponding code snippet and intended functionality. The exercises cover basic programming concepts such as loops, conditionals, and input/output operations.

Uploaded by

Adil Shahzad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Chap 5 all Exercise solved program

Q1 Write series of Even No


{
int j;

for(j=2; j<51; j=j+2)

printf(" %d ", j);


return 0;
}

Q2 Write Multiple of 5 table of 5


{
int j;

for(j=50; j<=5; j=j-5)

printf("%d ",j);
return 0;
}

Q3 print the series of no 1 to 10


{
int j, sum, square;

for(j=1; j<=10; j++)

square=j*j;
sum= sum+square;
printf(" %d ",sum);
return 0;
}

Q4 Write alphabet in reverse order


{
float n;
n=90;
while(n>=65)
{
printf("%c",n);
n=n-1;
}
return 0;
}

Q5 Write a table using while loop


{

1
int n,i;
i=1;
printf("Enter a nO you want to print of a table");
scanf("%d",&n);
while(i<=10)
{
printf("%d\t%d\t%d", n, i, /*n*i);
i=i+1;
}
return 0;
}

Q6 class of 15 student
{
int student[15], i,sum=0;
float ave;
for( i=1 ; i<=15; i++)
{
printf(" Enter marks of student");
scanf("%d",&student[i]);
if( i > 100 <1)
{
printf(" Enter marks of student");
scanf("%d",&student);
}
sum=sum+student[i];
}
ave=sum/15;
printf("Average is %f",ave)
getch;
}

Q 7 20 students
int student[20], i,sum=0,pass_student,fail_student;
float ave;
for( i=1 ; i<=20; i++)
{
printf(" Enter marks of student");
scanf("%d",&student[i]);
if( student[i]>=33)
{
pass_stduent++;
}
else
{
fail_student++;
}

printf("\n The Number of pass student",pass_student);


printf("\n The Number of fail student",fail_student);
getch;
}
2
Q8 Print 60 *
/*{
int j;
do
printf("*");
while(j<60);

return 0;
}*/
//

Q 9 Write table of series


{

int n,k;
k=1;
printf("Enter a no you want to print ");
scanf("%d",&n);
while (n>=10);
printf("\n%d\t%d\t%d",n,k,n*k);
n=n+1;
return 0;

Q4 Print table of any no


{
int n,k;
printf("Enter a no you want to print ");
scanf("%d",&n);
for( k=1; k<11; k++)
printf("\n%d\t%d\t%d",n,k,n*k);
return 0;
}
Sum all odd no
{
int sum,k;
k=1;
for( k=1; k<10; k=k+2)
sum=sum+k;
printf("sum is %d",sum);
return 0;
}

Q6 Write a number and print its factorial


/*{
int n,k, fact;
3
printf("Enter a no you want to print ");
scanf("%d",&n);
fact=1;
for( k=1; k<=n; k++)
fact=fact*k;
printf("\n Factorial of %d is %d",n,fact);
return 0;
}
Q7 Write program to print 1 4 7 10 13 16 19 22 25 28 31 34
37 40{
int n,k;

for( k=1; k<41; k=k+3)


printf("\n%d",k);
return 0;
}

You might also like