see
A
WAP to take ‘n’ numbers as input and save it in an array and pass entire array to a function, which finds largest number, using pointers
WAP to take ‘n’ numbers as input and save it in an array and pass entire array to a function, which finds largest number, using pointers
#include<stdio.h>
#include<conio.h>
void max(int a[]);
void main()
{
int a[20],i,d,j,k;
clrscr();
for(i=1;i<=5;i++)
{
scanf("%d",&d);
a[i]=d;
}
max(a);
//printf("%d",j);
getch();
}
void max(int a[])
{ int i,e=0;
for(i=1;i<=5;i++)
{
if(a[i]>e)
{
e=a[i];
}
}
printf("%d",e);
}
WAP to store ‘n’ numbers in an array and pass each array element to a function which finds if number is even or odd
WAP to store ‘n’ numbers in an array and pass each array element to a function which finds if number is even or odd
#include<stdio.h>
#include<conio.h>
void main()
{
int j,a[40];
int i,s=0;
float d;
clrscr();
void ret(int);
printf("Enter the Numbers ");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
ret(a[i]);
getch();
}
void ret(int a[])
{
if(a[]%2==0)
printf("%d is even",a[]);
else
printf("%d is odd",a[]);
}
WAP to enter marks of 30 students, save it in an array and find the average of the marks.
WAP to enter marks of 30 students, save it in an
array and find the average of the marks.
#include<stdio.h>
#include<conio.h>
void main()
{
int j,a[40];
int i,s=0;
float d;
clrscr();
printf("Enter the Numbers ");
for(i=0;i<30;i++)
scanf("%d",&a[i]);
for(i=0;i<30;i++)
{
s=s+a[i];
}
d=(s/30);
printf("The average of Student is = %f",d);
getch();
}
WAP to take any single alphabet as input and find out if user has entered it in upper case or lower case using switch.
WAP to take any single alphabet as input and find
out if user has entered it in upper case or lower case using switch.
#include<stdio.h>
#include<conio.h>
void main()
{
int j;
char i;
clrscr();
printf("Enter the Alphabet ");
scanf("%c",&i);
if(i>='A' && i<='Z')
j=1;
else if(i<'z' && i>='a')
j=2;
switch(j)
{
case 1:printf("Upper case");
break;
case 2:printf("Lower Case");
break;
default:printf("Wrong input");
}
getch();
}
#include<conio.h>
void main()
{
int j;
char i;
clrscr();
printf("Enter the Alphabet ");
scanf("%c",&i);
if(i>='A' && i<='Z')
j=1;
else if(i<'z' && i>='a')
j=2;
switch(j)
{
case 1:printf("Upper case");
break;
case 2:printf("Lower Case");
break;
default:printf("Wrong input");
}
getch();
}
WAP to take the percentage marks of a student as input and find which division the student falls into using switch statement.
WAP to take the percentage marks of a student as input and find which division the student falls into using switch statement.
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
printf("Enter the Percentage ");
scanf("%d",&i);
if(i>=90 && i<=100)
j=1;
else if(i<90 && i>=70)
j=2;
else if(i<70 && i>=60)
j=3;
else if(i<60 && i>=45)
j=4;
else if(i<45 && i>=35)
j=5;
else if(i<35 && i>=0)
j=6;
switch(j)
{
case 1:printf("Division A");
break;
case 2:printf("Division B");
break;
case 3:printf("Division C");
break;
case 4:printf("Division D");
break;
case 5:printf("Division E");
break;
case 6:printf("Division F");
break;
default:printf("Wrong input");
}
getch();
}
WAP to print 2 columns of numbers from 1 to 100 and 100 to 1, provided that there should never be same numbers in a row… ex: 2 2 is never printed
WAP to print 2 columns of numbers from 1 to 100 and 100 to 1, provided that there should never be same numbers in a row… ex: 2 2 is never printed
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1,j=100;i<=100,j>=1;i++,j--)
{
if(i==j)
continue;
else
printf("%d,%d ,",i,j);
}
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j;
clrscr();
for(i=1,j=100;i<=100,j>=1;i++,j--)
{
if(i==j)
continue;
else
printf("%d,%d ,",i,j);
}
getch();
}
WAP to print prime numbers between 1-200 using do while loop.
WAP to print prime numbers between 1-200 using do
while loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int a[100];
int i,k=1,j;
int count=0;
clrscr();
a[k]=1;
i=3;
do{
j=2;
do{
if(i%j==0)
{
count=1;
}
j++;
}while(j<i);
if(count==0)
a[++k]=i;
count=0;
i++;
}while(i<=200);
i=1;
do{
printf("%d,",a[i]);
i++;
}while(i<=k);
getch();
}
WAP to print first 100 prime numbers using for loop
WAPto print first 100 prime numbers using for loop
#include<stdio.h>
#include<conio.h>
void main()
{
int a[70];
int i,k=1,j;
int count=0;
clrscr();
a[k]=1;
for(i=3;i<=100;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
count=1;
}
}
if(count==0)
a[++k]=i;
count=0;
}
for(i=1;i<=k;i++)
{
printf("%d,",a[i]);
}
getch();
}
Subscribe to:
Posts (Atom)