100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Computer system £20.49   Add to cart

Lecture notes

Computer system

 0 view  0 purchase

Computer system, computer science, computer skills, computer language

Preview 4 out of 31  pages

  • July 24, 2023
  • 31
  • 2017/2018
  • Lecture notes
  • Prof
  • All classes
All documents for this subject (12)
avatar-seller
akhilagouri
Ex : printf(“ hello “);-> hello
printf(“a”); -> a
printf(“%d”, a); -> a value
printf(“%d”); -> no display

scanf() : input data can be entered into the computer using the standard input „C‟ library
function called scanf(). This function is used to enter any combination of input.

Syntax : scanf(“control string “,&var1, &var2,----, &varn);

The scanf() function is used to read information from the standard input device (keyboard).

Ex : scanf(“ %d “,&a);-> hello


Each variable name (argument) must be preceeded by an ampersand (&). The (&) symbol gives
the meaning “address of “ the variable.

Unformatted I/O functions:
a) Character I/O
b) String I/O

a) character I/O:

1. getchar(): Used to read a character from the standard input
2. putchar(): Used to display a character to standard output
3. getch() and getche(): these are used to take the any alpha numeric characters
from the standard input
getche() read and display the character
getch() only read the single character but not display
4. putch(): Used to display any alpha numeric characters to standard output

a) String I/O:

1. gets(): Used for accepting any string from the standard input(stdin)
eg:gets()

2. puts(): Used to display a string or character array Eg:puts()
3. Cgets():read a string from the console eg; cgets(char *st)
4. Cputs():display the string to the console eg; cputs(char *st)



C PROGRAMMING Page 30

,OPERATORS AND EXPRESSIONS:
Operators : An operator is a Symbol that performs an operation. An operators acts some
variables are called operands to get the desired result.

Ex : a+b;
Where a,b are operands and + is the operator.

Types of Operator :
1) Arithmetic Operators.
2) Relational Operators.
3) Logical Operators.
4) Assignment Operators.
5). Unary Operators.
6) Conditional Operators.
7) Special Operators.
8) Bitwise Operators.
9) Shift Operators.



Arithmetic Operators
An arithmetic operator performs mathematical operations such as addition, subtraction and
multiplication on numerical values (constants and variables).
C Program to demonstrate the working of arithmetic operators
#include <stdio.h>
void main()
{
int a = 9,b = 4, c;

c = a+b;
printf("a+b = %d \n",c);

c = a-b;
printf("a-b = %d \n",c);

c = a*b;
printf("a*b = %d \n",c);

c=a/b;
printf("a/b = %d \n",c);

c=a%b;
printf("Remainder when a divided by b = %d \n",c);


}

C PROGRAMMING Page 31

,Output
a+b = 13
a-b = 5
a*b = 36
a/b = 2
Remainder when a divided by b=1



Relational Operators. A relational operator checks the relationship between two operands.
If the relation is true, it returns 1; if the relation is false, it returns value 0.
Operands may be variables, constants or expressions.

Relational operators are used in decision making and loops.




Operator Meaning Example Return value
< is less than 2<9 1
<= is less than or equal to 2<=2 1
> is greater than 2>9 0
>= is greater than or equal to 3>=2 1
== is equal to 2==3 0
!= is not equal to 2!=2 0

// C Program to demonstrate the working of relational operators

#include <stdio.h>

int main()

{

int a = 5, b = 5, c = 10;

printf("%d == %d = %d \n", a, b, a == b); // true

printf("%d == %d = %d \n", a, c, a == c); // false

printf("%d > %d = %d \n", a, b, a > b); //false

printf("%d > %d = %d \n", a, c, a > c); //false



C PROGRAMMING Page 32

, printf("%d < %d = %d \n", a, b, a < b); //false

printf("%d < %d = %d \n", a, c, a < c); //true

printf("%d != %d = %d \n", a, b, a != b); //false

printf("%d != %d = %d \n", a, c, a != c); //true

printf("%d >= %d = %d \n", a, b, a >= b); //true

printf("%d >= %d = %d \n", a, c, a >= c); //false

printf("%d <= %d = %d \n", a, b, a <= b); //true

printf("%d <= %d = %d \n", a, c, a <= c); //true

return 0;

}

Output

5 == 5 = 1

5 == 10 = 0

5>5=0

5 > 10 = 0

5<5=0

5 < 10 = 1

5 != 5 = 0

5 != 10 = 1

5 >= 5 = 1

5 >= 10 = 0


C PROGRAMMING Page 33

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller akhilagouri. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £20.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67474 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£20.49
  • (0)
  Add to cart