Skip to main content

C Programming Basics

 

Keywords

Keywords are predefined, reserved words used in programming that have special meanings.

ex:- int money;
Here, int is a keyword that indicates money is a variable of type int (integer).

Identifiers

Identifier refers to name given to entities such as variables, functions, structures etc.

Variables

In programming, a variable is a container (storage area) to hold data.
ex:- int playerScore = 95;
Here, playerScore is a variable of int type

Constants

If you want to define a variable whose value cannot be changed, you can use the const keyword.
ex:- const double PI = 3.14;

Data Types

Data types are declarations for variables.This determines the type and size of data associated with variables.

Input Output (I/O)

use scanf() function to take input from the user, and printf() function to display output to the user

#include <stdio.h>
int main()
{
int a;
float b;
printf("Enter integer and then a float: ");
// Taking multiple inputs
scanf("%d%f", &a, &b);
printf("You entered %d and %f", a, b);
return 0;
}

Output

Enter integer and then a float: -3 3.4
You entered -3 and 3.400000

Programming Operators

An operator is a symbol that operates on a value or a variable.
Ex:- +,-, *,%

practice

C program to print a sentence
C program to print an integer entered by the user
C program to add two integers entered by the User
C program to multiply two floating-point numbers
C program to find ASCII value of a character entered by the user
C program to find quotient and remainder of Two Integers
C program to find the size of int, float, double and char
C program to swap two numbers

Comments

Popular posts from this blog

Frontend Vs Backend Coding

Frontend Vs Backend Coding Let us understand how this development is done.Development is divided into two parts frontend development and backend development. The front end, also called “ client-side ” programming, is what happens in the browser. It’s everything the user sees and interacts with. The back end, also called “ server-side ” programming, happens on the server and the database. It’s the machinery that works behind the scenes. developing a website Front-end Development Part of a website that the user interacts. Everything that users experience directly: text colors and styles, images, graphs and tables, buttons, colors, and navigation menu. HTML, CSS, and Javascript are the languages used for Front End development. HTML ( HyperText Markup Language) adds content on the web page with the help of HTML elements CSS  (Cascading Style Sheets)  adds styles to HTML elements Javascript adds behavior in the webpage   Ex: calculate, manipulate, and validate d...

C programming with practical Questions

Basics C language is one of the powerful languages. Below are some of the features of C language. Ø   Reliability Ø   Portability Ø   Flexibility Ø   Interactivity Ø   Modularity Ø   Efficiency and Effectiveness   1) C program to calculate Simple Interest. Given principal (amount), time and interest rate by user, calculate simple interest based on given rate of given time period. 2) Ask the employee details   Name   initial---(surname only single letter, take datatype as char)   Age   Salary-(take datatype double)   expected expenditure   actual expenditure   and   display name and remaining balance of salary.    Operators The symbols which are used to perform logical and mathematical operations in a C program are called C operators. These C operators join individual constants and variables to form expressions. Operators...

Software Vs Hardware

Software Vs Hardware Hardware is a physical part of a computer. Software which cannot be touched,can perform tasks on the computer. Software works on a hardware. For Example ATM machine, ATM machine physical parts are Hardware. The working functionality of an ATM (like displaying account balance,etc) is software.  Examples of software products are  Microsoft suite of products (Office, Excel, Word, PowerPoint, Outlook, etc.) Internet browsers like Firefox, Safari, and Chrome.   Developing a Software Program Well, Software is a task which works on hardware. And hardware can understand only binary language (ex:- 10101) which can be formed by power. Binary language(Machine Code) is known as a low-level language. For humans it's very tough to write every task in binary language.   Then mid-level languages are created which can be understood by the user and as well as the system.   Then High-level languages came with more user friendly,The programming languages like c...