see

A

WAP to accept ‘n’ numbers as input and find the largest number of them using while loop


WAP to accept ‘n’ numbers as input and find the largest number of them using while loop

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[5],s=0;
 int i;
 clrscr();
 for(i=0;i<5;i++)
 {scanf("%d",&a[i]);
 }
 i=0;
 while(i<5)
 {
  if(a[i]>s)
   s=a[i];
  i++;
 }
 printf("%d",s);
 getch();
}

Read More »

WAP to suppress not reachable code warning using #pragma directive


WAP to suppress not reachable code warning using #pragma directive
#include<stdio.h>
#include<conio.h>
#pragma warn -rvl
#pragma warn -par
#pragma warn -rch
int f1()
{
int a;
}
void f2(int x)
{
printf("asd");
}
int f3()
{
 int a=1;
 return a;
 a++;
}
int main()
{
 f1();
 f2(2);
 f3();
 getch();
}

Read More »

WAP to swap 2 numbers using swap as macro


WAP to swap 2 numbers using swap as macro

#include<conio.h>
#include<stdio.h>
#define swap(x,y) { x=x+y; y=x-y; x=x-y;}
void main()
{
  int a=3,b=4;
  swap(a,b);
  printf("%d,%d",a,b);
  getch();
}

Read More »

WAP to demonstrate the scope rule of automatic variables


WAP to demonstrate the scope rule of automatic variables


#include<conio.h>
#include<stdio.h>
int a=1;
void main()
{
auto int a;
clrscr();
printf("\nvalue of a: ");
scanf("%d",&a);
printf("\na: %d",a);
{
    a=0;
    printf("\na: %d",a);
    a++;
}
    printf("\na: %d",a);
getch();
}

Read More »

WAP to take the percentage marks of a student as input and find which division the student falls into using logical operators


WAP to take the percentage marks of a student as input and find which division the student falls into using logical operators

#include<stdio.h>
#include<conio.h>
void main()
{
  clrscr();
  float p;
  printf("Enter the Percentage ");
  scanf("%f",&p);
  if(p>=90 && p<=100)
  printf("Division = A");
  else if(p<90 && p>=75)
  printf("Division = B");
  else if(p<75 && p>=55)
  printf("Division = C");
  else if (p<55 && p>=35)
  printf("Division = D");
  else if(p<35 && p>=0)
  printf("Division = E");
  else
  printf("Wrong input");
  getch();
}

Read More »

WAP to find the simple interest by taking P, n and r as inputs


WAP to find the simple interest by taking P, n and r as inputs
#include<stdio.h>
#include<conio.h>
void main()
{
  clrscr();
  float p,n,r;
  printf("Enter the Principle");
  scanf("%f",&p);
  printf("Enter the Rate");
  scanf("%f",&r);
  printf("Enter the Time");
  scanf("%f",&n);
  float SI=((p*r*n)/100);
  printf("Simple Interest is %f ",SI);
  getch();
}

Read More »

WAP to find the area of rectangle by taking length and breadth as inputs


WAP to find the area of rectangle by taking length and breadth as inputs


          #include<stdio.h>
#include<conio.h>

void main()
{   clrscr();
    float l,b,r;
    printf("Area of Rectangle\n");
    printf("Enter the length");
    scanf("%f",&l);
    printf("Enter the Breath");
    scanf("%f",&b);
    r=l*b;
    printf("Area of the Rectangle is %f",r,"square meter");
    getch();
}

Read More »
Copyright © 2013. BloggerSpice.com - All Rights Reserved
Customized by: MohammadFazle Rabbi | Powered by: BS
Designed by: Tilabs