The following C program implements Simulation of priority scheduling (CPU Scheduling algorithm). Each process or job is given a priority. The priority is represented using a positive integer. The priority increases as the value of the integer decreases.
Program:
#include<stdio.h>
struct process{
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label programs. Show all posts
Showing posts with label programs. Show all posts
2 Different C and C++ Programs to Check Whether a Given String is Palindrome or Not
Here i am writing two different programs to check whether a given string (text) us palindrome or not. There are C and C++ programs for this.
C Programs:
(i) Using string functions:
(ii) Comparing Character by Character
C++ Programs:
(i) Using String functions:
C Programs:
(i) Using string functions:
#include<stdio.h> #include<string.h> #include<conio.h> void main() { char a[100],b[100]; printf("Enter the string to check if palindrome or not\n"); gets(a); strcpy(b,a); strrev(b); if(strcmp(a,b)==0) printf("\nEntered string is palindrome"); else printf("\nEntered string is not palindrome"); getch(); }
(ii) Comparing Character by Character
#include<string.h> #include<stdio.h> #include<conio.h> void main() { int len,i; char a[100]; printf("Enter the string to check whether it is palindrome or not\n"); gets(a); len=strlen(a); for(i=0;i<len/2;i++) { if(a[i]!=a[len-i-1]) break; } if(i==len/2) printf("\nEntered string is palindrome"); else printf("\nEntered string is not palindrome"); getch(); }
C++ Programs:
(i) Using String functions:
Labels:
$ccpp
,
c language
,
c plus plus
,
C programming
,
C++
,
code
,
coding
,
cpp
,
programming
,
programming language
,
programs
,
project
,
source code
Program to Understand Bitwise Operators
This program is to understand working of bitwise operators
#include<stdio.h> main () { unsigned int a = 60; /* 60 = 0011 1100*/ unsigned int b = 13; /* 13 = 0000 1101 */ printf ("a=60 ( 0011 1100)\nb=13 ( 0000 1101)\n"); int c = 0; c = a&b ; /* 12 = 0000 1100 */ printf ("a&b=%d\n",c ); c = a | b ; /* 61 = 0011 1101 */ printf ("a|b=%d\n",c ); c = a ^ b ; /* 49 = 0011 0001 */ printf ("a^b=%d\n", c ); c = ~ a; /*-61 = 1100 0011 */ printf ("~a=%d\n" , c ); c = a << 2 ; /* 240 = 1111 0000 */ printf ("a<<2=%d\n" , c ); c = a >> 2 ; /*15 = 0000 1111*/ printf ("a>>2=%d\n" , c ); }
Labels:
$studymat
,
and operator
,
bit wise
,
bitwise
,
c program
,
C++
,
example
,
exor
,
How to use
,
logical
,
manipulation
,
not operation
,
operations
,
operators
,
or operation
,
programming
,
programs
,
usage
,
xor
Subscribe to:
Posts
(
Atom
)