Posts

Showing posts with the label Assignment 1

Assignment 1 Question 3

/* name: vinayak sharma smvdu, jammu ECE code description: user enters 3 numbers. the 3 numbers get compared, if a>b>c then result is diplayed as 1 or else 0. */ #include <stdio.h> int main()   {   int a, b, c;   scanf("%d", &a); //this will input a   scanf("%d", &b); //this will input b   scanf("%d", &c); //this will input c     if (( a>b ) && ( b>c ) && ( a>c )) // logical operation comparing the 3 numbers   {     printf("1");   }   else //if the statement holds false then this else statement will be displayed   {     printf("0");   }   return 0; }   

Assignment 1 Question 2

/* name: vinayak sharma smvdu, jammu ECE code description: checking if m is exact multiple of n. output will be 0 if m is not a multiple of n. output will be m/n if m is a multiple of n */ #include <stdio.h> int main() {   int m, n, a;      //decleration of variables   scanf("%d", &m);  //taking the input of m   scanf("%d", &n);  //taking the input of n     if ( m%n == 0)    //logical operation for checking if m is a multiple of n   {     a = m/n;        // m divided by n stored in a variable     printf("%d",a);   }   else              //if the logic holds false this else statement will be carried out    {     printf("0");   }   return 0; }

Assignment 1 Question 1

/* Name :- Vinayak Sharma SMVDU, jammu ECE code description:- This code will compare the entered input numbers. if a number is repeated more than once the output will be 0 and if all the numbers are different the output will be 1. */ #include <stdio.h> int main() {     int a, b, c;     scanf("%d", &a); /*this will input the first number*/     scanf("%d", &b); /*this will input the second number*/     scanf("%d", &c); /*this will input the third number*/         if ((a == b) || (b == c) || (a == c)) /*if statement with OR operator which will check if 2 or more numbers are same*/                                          {                                             printf("0"); /* this...