Category: Learn C Online

Program to Calculate Length of a String (Using strlen in-built function) 5

Program to Calculate Length of a String (Using strlen in-built function)

#include #include #include void main(){ int strlength; char *str; clrscr(); printf(“\nEnter the string: “); gets(str); strlength=strlen(str); printf(“\nThe length of the string is %d.”,strlength); getch(); } Output: Enter the string: Learn C Online The length of the string is 14.

Program to Calculate Length of a String (without using strlen in-built function). 30

Program to Calculate Length of a String (without using strlen in-built function).

#include #include void main(){ char *str; int count = 0,i; clrscr(); printf(“\nEnter the String: “); gets(str); for(i=0;str[i]!=’\0′;i++){ count++; } printf(“\nThe length of the string is %d.”,count); getch(); } Output: Enter the String: Learn C Online The length of the string is 14.

Strings in C Programming Language 19

Strings in C Programming Language

A string in C is a series of characters in a group that occupy contiguous memory. A group of characters (Alphabets, digits and special characters) is called as a string. Example 1: “Thank you for visiting www.learnconline.com” “www.learnconline.com is excellent site for beginners. This is example of strings in C.” A string in C should always be enclosed with in double quotes (“). If single quote is used then it is treated as character. Hence ‘A’ is different from “A”. Every string ends with a null character (‘\0’). Note that \0 is a single character. So when it has to...

Program in C to reverse a given Number 9

Program in C to reverse a given Number

Below is the C program to reverse a given number. This C program will accept a number (in a variable named “num”) and performs an operation to reverse the number. #include <stdio.h> #include <stdlib.h> int main(void) { int num=1234, newNum=0; while(num!=0){ newNum=newNum*10 + num%10; num=num/10; } printf(“\n”); printf(“%d”, newNum); return 1; } Output: 4321 Explanation: The statement while(num!=0) will be executed till value of num !=0 num%10 (read as num mod 10) will return the last digit. So in 1st iteration, it will return 4. So, newNum will become–> 0*10 + 4 –>4 Next line i.e. num/10 will return 123...

C data types 28

Data Types in C

The above video is an extract from the online course – “C Programming: The ultimate guide for beginners” which we are currently working on. Consider subscribing to Youtube channel – Aptuts in order to get latest updates on new videos and online C programming course. Data types in C determine the following:• Range of the data• Type of the data stored• Number of bytes it occupies in memory C supports following data types:• int – occupies 4 bytes of memory in 32-bit compiler• float – occupies 4 byes of memory• double – occupies 8 bytes of memory• char – occupies...

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet