#programs

Q-1:- Write a program to print your details. 
#include<stdio.h>
#include<conio.h>
void main( )
   clrscr( );
   printf( "SIMS");
   printf("\nBCA 1st semester");
   printf("\nAnubhav");
    getch( );
}
Output:-
SIMS
BCA 1 st semester
Anubhav

Q-2:- Write a program to sum of two number.
#include<stdio.h>
#include<conio.h>
void main( )
{
 int a,b,sum;
 clrscr( );
 printf("Enter any two number a and b :");
 scanf("a=%d,b=%d",&a,&b);
 sum=a+b;
 printf("\nsum=%d",sum);
  getch( );
}
Output:-
Enter any two number a and b:
a=5,b=3
sum=8

Q-3:- Write a program to subtract of two number.
#include<stdio.h>
#include<conio.h>
void main( )
{
  int a,b,sub;
  clrscr( );
  printf("Enter any two number a and b :");
  scanf("a=%d,b=%d",&a,&b);
  subtract=a-b;
  printf("\nsubtract=%d",sub);
  getch( );
}
Output:-
Enter any two number a and b:
a=5,b=3
subtract=2

Q-4:- Write a program to multiple two number.
#include<stdio.h>
#include<conio.h>
void main( )
{
  int a,b,m;
  clrscr( );
  printf("Enter any two number a and b :");
  scanf("a=%d,b=%d",&a,&b);
  m=a*b;
  printf("\nm=%d",m);
  getch( );
}
Output:-
Enter any two number a and b:
a=5,b=3
m=15

Q-5:- Write a program to swap the value of two variable by using third variable.
#include<stdio.h>
#include<conio.h>
void main( )
{
  int a,b,c
  clrscr( );
  printf("Enter any two number a and b :");
  scanf("a=%d,b=%d",&a,&b);
  c=a;
  a=b;
  b=c;
  printf("after swaping the value of a and b:");
  printf("\na=%d,b=%d",a,b);
  getch( );
}
Output:-
Enter any value of a and b:
a=5,b=6
after swaping the value of a and b:
a=6,b=5

Q-6:-WAP to find the data(ROLL  NUMBER, NAME, DEPARTMENT,COURSE, YEAR OF JOINING) of student according to roll number using structure.

#include<stdio.h>
#include<conio.h>
struct class
{
  int rollno;
  char name[10];
  char department[10];
  char course[10];
  int yearofjoining;
};
void main( )
{ int i , r;
  struct class b[5];
  clrscr( );
  for(i=0;i<5;i++)
  {
  scanf("%d%s%s%s%d",&b[i].rollno,&b[i].name,
                 &b[i].department,&b[i].course,
                 &b[i].yearofjoining);
  }
 printf("Enter the roll number:");
 scanf("%d",&r);
 for(i=0;i<5;i++)
 { if(r==b[i].rollno)
    {
       printf("%d\n%s\n%s\n%s\n%d",b[i].rollno,
                b[i].name,b[i].department,b[i].course,
                b[i].yearofjoining);
       break;
    }
   else
    {
      printf("roll number is not found !");
     }
}
 getch( );
}
Output:-
1 abhi computer bca 2021
2 abhijeet computer  bca 2021
3 Atul  computer bca 2021
4 Anubhav computer bca 2021
5 adesh computer bca 2021
Enter the roll number: 4
4
Anubhav
computer
bca
2021

 Q-7-Write a program to find prime number.

#include <stdio.h>
int main()
{
int n, i, flag = 0;
printf("Enter a positive integer: ");
  ", &n);
// 0 and 1 are not prime numbers
// change flag to 1 for non-prime number
  if (n == 0 || n == 1)
    flag = 1;

 for (i = 2; i <= n / 2; ++i) {
 // if n is divisible by i, then n is not prime
    // change flag to 1 for non-prime number
    if (n % i == 0) {
      flag = 1;
      break;
    }
  }

  // flag is 0 for prime numbers
  if (flag == 0)
    printf("%d is a prime number.", n);
  else
    printf("%d is not a prime number.", n);

  return 0;
}
🥰😍🥰thanks






Comments

Popular posts from this blog