Skip to main content

Posts

Showing posts from October, 2020

Logical Reasoning

Quiz 3:-   3. In a code language, BROKE is written as DOSFK, START is written as UQEMZ, then INDIA is written as a. KHDKG b. DHGKK c. KKHDG d. KHGKD Answer:- c. KKHDG Explanation: Alphabet Series - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z The coding follows the rule +2, -3, +4, -5, +6, etc. That means B+2=D R-3=O O+4=S, etc.

Logical Reasoning.

  Quiz 2:- 2.In a code language QUEEN is written as OVCFL, then KING is written as a. IJLH b. MKOF c. PHIK d. FOKM Answer:-  a. IJLH Explanation: Alphabet Series - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z The coding follows the rule -2, +1, -2, +1, etc. That means Q -2 = O U+1=V E-2=C, etc.

Logical reasoning .

Quiz 1:-  1. If EDUCATION is written as 5421312091514 then how is CAT written? a. 13120 b. 312 c. 3120 d. 31209 Answer :-   c. 3120 Explanation :-  Alphabets and their positions Check alphabets and their positions. C=3      A=1       T=20 CAT = 3120.

C if. .else Statement.

C if. .else Statement. C if Statement  The syntax of the if statement in C programming is: Syntax : if (test expression) { // statements to be executed if the test expression is true } How if statement works? 1: The if statement evaluates the test expression inside the parenthesis (). 2: If the test expression is evaluated to true, statements inside the body of if are executed. 3: If the test expression is evaluated to false, statements inside the body of if are not executed. Example 1: if statement #include <stdio.h>  void main() { int x,y; printf( "Enter the Value of x: " ); scanf( "%d" ,&x); printf( "Enter the Value of y: " ); scanf( "%d" ,&y); if (x<y) { printf( "\n%d is less than %d" ,x,y); } } OUTPUT:- Enter the Value of x: 10 Enter the Value of y: 20 10 is less than 20    Program File: (click the following .c file to get the program file)                        ...

C program to convert temperature from Fahrenheit to Celsius and vice versa.

Program:- #include <stdio.h> void main() {     float fh,cl;     int choice;     printf( "1:Convert temperature from Fahrenheit to Celsius." );     printf( "\n2:Convert temperature from Celsius to Fahrenheit." );     printf( "\nEnter your choice (1, 2): " );     scanf( "%d" ,&choice);     if (choice ==1)     {         printf( "Enter temperature in Fahrenheit: " );         scanf( "%f" ,&fh);         cl= (fh - 32) / 1.8;         printf( "\nTemperature in Celsius: %.2f" ,cl);     }     else if (choice==2)     {         printf( "Enter temperature in Celsius: " );         scanf( "%f"...

C Multi-Dimensional Arrays.

Multi Dimensional Array      An array having more than one subscript or dimension is known as multi dimensional array.                 i.e.:  int arr[3][3].  Multi dimensional arrays are also known as arrays of arrays or matrix. Syntax - Multi Dimensional Array   In C, Multi-Dimensional arrays can be declared as follows: Syntax: Datatype  var_name[size1][size2][size3]......................[size n]; So, in the same way, we can declare the 2-D array as: 1. Two Dimensional array requires two subscript variables 2. In the following syntax size1 represents no of rows whereas size2 represents no of columns. Syntax: data-type varname [size1][size2];           e.g. :    int c[2][4]; So, in the same way, we can declare the 3-D array as: Syntax: Datatype  var_name[size1][size2][size3];         e.g. :    int c[2][3][4]; Two-dimensional array program :-...

Finding ASCII Values of c program.

  Program:- #include <stdio.h> void main() {     char c;     printf( "Enter a character : " );     scanf( "%c" ,&c);     printf( "\n\nASCII value of %c = %d" ,c,c);       printf( "\n\nCoding is interesting !\n\n" ); }      Output:- Enter a character : a ASCII value of a = 97   Coding is interesting ! Program File: (click the following .c file to get the program file)                                  ASCII.c

Find Average of class using C-language

  PROGRAM:-  #include <stdio.h> void main() { int i,j,sum=0,num; int marks[100]; float avg; printf( "Enter number of students in class :\n" ); scanf( "%d" ,&num); printf( "Enter marks of all students :\n" ); for (i=0;i<num;i++) { scanf( "%d" ,&marks[i]); sum+=marks[i]; } avg=sum/num; printf( "Average of class is %f\n" ,avg); } OUTPUT :- Enter number of students in class : 10 Enter marks of all students : 50  60  65  70  80  35  48  90  88  78 Average of class is 66.000000 Program File: (click the following .c file to get the program file)                      Average_Class.c

C One Dimensional Array.

 C One Dimensional Array What is One Dimensional Array ?          An Array which has only one subscript is known as One Dimensional Array.          i.e.  int  arr[10]. Syntax :-             Data_type  Variable_name[Size]; Rules For Declaring One Dimensional Array : 1: An Array variable must be declared before being used in Program. 2: The declaration must have a datatype (int , float , char , double , etc..), variable name , subscript. 3: The subscript represents the size of the Array. if the size if  5 , we can store 5 elements. 4: An Array index always starts from 0.              If an array variable is declared as arr[15] , then it range from 0 to 14. 5: Each array elements stored in separate memory location. In C-language an Array variable is also initialize without mentioning the size of an Array. Declaration :-   1 :  int   Sala...

C Program to find Area of Rectangle.

  PROGRAM :- #include <stdio.h> void main() { float height , width ; float Area; printf( "Enter Height of Rectangle: " ); scanf( "%f" ,&height); printf( "Enter width of Rectangle: " ); scanf( "%f" ,&width); // Formula (Area of Rectangle=height * width) Area = height*width; printf( "\nThe Area of Rectangle is = %.2f" , Area); } OUTPUT :- Enter Height of Rectangle: 10 Enter width of Rectangle: 5.5 The Area of Rectangle is = 55.00

C Program to Print Area of Circle.

  Area of Circle in C-language : C Program to find Area of Circle, In this Program Pi(Ï€) is assumed to be 3.14159. PROGRAM to find Area of Circle: #include <stdio.h> void main() { float    Radius, Area; printf( "Enter Radius of the circle: " ); scanf( "%f" , &Radius); // Formula (Area of Circle = Ï€ . Radius ² ) Area = 3.14159*Radius*Radius; printf( "\nThe Area of Circle is = %f" ,Area); } OUTPUT :- Enter Radius of the circle: 10 The Area of Circle is = 314.158997

C Program to check number is Positive or Negative.

  PROGRAM :- #include <stdio.h> void main() { int num; printf( "Enter a number :" ); scanf( "%d" , &num);   if (num >= 0)      printf( "%d is a positive number \n" , num);   else      printf( "%d is a negative number \n" , num); } OUTPUT :-  OUTPUT 1:      Enter a number :10     10 is a positive number OUTPUT 2:      Enter a number : -10     -10 is a negative number

C Program to check whether a number is Even or Odd.

  PROGRAM :- #include <stdio.h> void main() { int num; printf( "Enter an integer: " ); scanf( "%d" , &num); if (num % 2 == 0)   printf( "\n The given number %d is even." , num); else   printf( "\n The given number %d is odd." , num); } OUTPUT :- Output 1 : Enter an integer: 10  The given number 10 is even. Output 2: Enter an integer: 9  The given number 9 is odd.

C Program for Modulo % operator

PROGRAM :-  #include <stdio.h> void  main() { int  a,b,result; printf( "Enter the value of a: " ); scanf( "%d" ,&a); printf( "Enter the value of b: " ); scanf( "%d" ,&b); result = a%b; printf( "\n The Answer is =>%d" ,result); } OUTPUT :- Enter the value of a: 10 Enter the value of b: 4  The Answer is =>2

Arrays in c-language

 Definition :- An Array is a group (or collection) of the same data types . For an example an int array holds the elements of int types while float array holds the elements of float types . How to declare an Array ?      datatype Array_name[array_size]; For example,       float   salary[5]; Keynotes :  1: Arrays have 0 as the First index, not 1 . In this example , salary[0] is the First element. 2: If the size of an array is  n , to access the last element, the n-1 index is used. In this example, salary[4] 3: Suppose the starting address of salary[0] is 2120d . then, the address of the salary[1] will be 2124d .  Similarly, the address of salary[2] will be 2128d and so on. This is because the size of a float is 4 bytes. How to initialize an array?   int salary[5] = { 10000 , 12000 , 12300 , 20000 , 21000 };  You can also initialize an array like this . int  salary[] = { 10000 , 12000 , 12300 , 20000 , ...

C program to print division of two numbers.

  PROGRAM :- #include <stdio.h> void main() { float a,b; float div; printf( "Enter the value of a: " ); scanf( "%f" ,&a); printf( "\nEnter the value of b: " ); scanf( "%f" ,&b); div=a/b; printf( "\nThe division of a/b is :%f" ,div); } OUTPUT :- Enter the value of a: 10 Enter the value of b: 3 The division of a/b is :3.333333

C program to print multiplication of two numbers.

  PROGRAM :-  #include <stdio.h> void main() { int a,b,mul; printf( "Enter the value of a: " ); scanf( "%d" ,&a); printf( "\nEnter the value of b: " ); scanf( "%d" ,&b); mul=a*b; printf( "\nThe Multiplication of a & b is :%d" ,mul); } OUTPUT :- Enter the value of a: 10 Enter the value of b: 5 The Multiplication of a & b is : 50

C program to print Substraction of two numbers .

 PROGRAM :- #include <stdio.h> void main() { int a,b,sub; printf( "Enter the value of a: " ); scanf( "%d" ,&a); printf( "\nEnter the value of b: " ); scanf( "%d" ,&b); sub=a-b; printf( "\nThe Substraction of a & b is :%d" ,sub); } OUTPUT :- Enter the value of a: 20 Enter the value of b: 5 The Substraction of a & b is :15

C program to print addition of two numbers .

 PROGRAM :- #include <stdio.h> void main() { int a,b,sum; printf( "Enter the value of a: " ); scanf( "%d" ,&a); printf( "\nEnter the value of b: " ); scanf( "%d" ,&b); sum=a+b; printf( "\nThe addition of a & b is :%d" ,sum); } OUTPUT :- Enter the value of a: 10 Enter the value of b: 20 The addition of a & b is : 30