EXP1 Writeup-1
EXP1 Writeup-1
Date of Performance :
Date of Submission :
AIM: Write programs to demonstrate different operators and Input Output operations in C.
1a. Write a C program to print student details.
1b. Write a C program to perform Arithmetic Operations.
1c. Write a C program to demonstrate unary, binary, bitwise, relational and logical operators.
SOFTWARE REQUIREMENT: Turbo C
THEORY:
In C, data input and output are typically handled using standard library functions provided in <stdio.h>. These functions allow you to read data from the user (input) and display
data to the user (output). Below are some of the most commonly used functions for input and output in C:
1.
Standard Input and Output:
2.
Header File:
o The <stdio.h> header file must be included to use standard input/output functions.
3.
Common Functions:
4.
Format Specifiers:
o Used in printf and scanf to define the type of data being handled.
Syntax
1.
printf: For formatted output.
Example:
2.
scanf: For formatted input.
Example:
scanf("%d", &x);
3.
getchar: To read a single character.
char c = getchar();
Example:
char c = getchar();
4.
putchar: To write a single character.
putchar(character);
Example:
putchar('A');
5.
gets: To read a string.
char[] gets(char[]);
Example:
char s[30];
gets(s);
6.
puts: To write a string.
puts(string);
Example:
puts("Hello, World!");
Format Specifiers
● %d: Integer
● %f: Float
● %c: Character
● %s: String
Operators:
1.
Arithmetic Operators
- Subtraction a - b
* Multiplication a * b
/ Division a / b
% Modulus (remainder) a % b
2. Relational Operators
!= Not equal to a != b
4. Bitwise Operators
| Bitwise OR ` a|b
^ Bitwise XOR a ^ b
~ Bitwise NOT ~a
5. Assignment Operators
6. Unary Operators
Experiment 1
AIM: Write program to demonstrate different operators and Input Output operations in C.
1a. Write a C program to print student details.
1b. Write a C program to perform Arithmetic Operations.
1c. Write a C program to demonstrate unary, binary, bitwise, relational and logical operators.
1a. Write a C program to print student details.
#include<stdio.h>
void main ()
{
char name[30];
int rno;
char div[10];
printf("Enter your name: ");
scanf("%s",name);
printf("enter your division (A/B/C): ");
scanf("%s",div);
printf("Enter your roll number:" );
scanf("%d", &rno);
puts("\nStudent Information");
printf("Entered Name: %s\n",name);
printf("Entered division: %s\n",div);
printf("Entered RollNo: %d",rno);
}
Output: