C Sheet1
C Sheet1
int main()
{
char ch;
ch = 'A';
cout << "The ASCII value of " << ch << " is " << int(ch)
<< endl;
return 0;
}
int main()
{
char ch = 'e';
if (isalpha(ch)) {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o'
|| ch == 'u' || ch == 'A' || ch == 'E'
|| ch == 'I' || ch == 'O' || ch == 'U') {
cout << ch << " is a vowel." << endl;
}
else {
cout << ch << " is a consonant." << endl;
}
}
else {
cout << ch << " is not an alphabet." << endl;
}
return 0;
}
int main()
{
string str = "GeeksforGeeks to the moon";
int vowels = 0;
return 0;
}
int main()
{
string str = "GeeksforGeeks";
int length = 0;
cout << "The length of the string is: " << length
<< endl;
return 0;
}
int main()
{
int j = 0;
j++;
}
cout << "String without vowels: " << str << endl;
return 0;
}
int main()
{
string str = "Gfg to the moon";
return 0;
}
C++
// C++ program to check if a given
// year is leap year or not
#include <iostream>
using namespace std;
// leap year
if (year % 4 == 0)
return true;
int main()
{
int year = 2000;
if (checkYear(year))
cout << "Leap Year";
else
cout << "Not a Leap Year";
return 0;
}
C++
int main()
{
int n = 12321;
if (checkPalindrome(n) == 1) {
cout << "Yes\n";
}
else {
cout << "No\n";
}
return 0;
}
C++
int main()
{
int n = 153;
int temp = n;
int ans = 0;
// function to calculate
// the sum of individual digits
while (n > 0) {
// condition to check
if (temp == ans) {
cout << ("Yes, it is Armstrong Number");
}
else {
cout << ("No, it is not an Armstrong Number");
}
return 0;
}
10. Write a Program to Find the Nth Term of the Fibonacci Series
C++
int fib(int n)
{
int first = 0, second = 1, ans;
if (n == 0)
return first;
return ans;
}
int main()
{
int n = 13;
C++
return result;
}
int main()
{
int a = 54, b = 33;
return 0;
}
12. Write a Program to Calculate the Lowest Common Multiple (LCM)
of Two Numbers
C++
// C++ program to
// Find LCM of two numbers
#include <iostream>
using namespace std;
int main()
{
int a = 24, b = 13;
cout << "LCM : " << lcm(a, b);
return 0;
}
C++
int main()
{
int arr[] = { 1, 2, 3, 4, 5 };
int N = sizeof(arr) / sizeof(arr[0]);
findMinMax(arr, N);
return 0;
}
C++
if (n < 2) {
cout << " Invalid Input ";
return;
}
int main()
{
int arr[] = { 21, 3, 15, 41, 34, 10 };
int n = sizeof(arr) / sizeof(arr[0]);
print2Smallest(arr, n);
return 0;
}
C++
// C++ Program to calculate
// sum of elements in an array
#include <iostream>
using namespace std;
return sum;
}
int main()
{
int arr[] = { 1, 23, 54, 12, 9 };
int n = sizeof(arr) / sizeof(arr[0]);
return 0;
}
C++
string isPalindrome(string S)
{
for (int i = 0; i < S.length() / 2; i++) {
if (S[i] != S[S.length() - i - 1]) {
return "No";
}
}
return "Yes";
}
int main()
{
string S = "GeekeeG";
return 0;
}
int main()
{
int len;
len = str.size();
return 0;
}
int main()
{
int oct, dec = 0, place = 0;
// 67 is an octal number with binary equivalent 110000
oct = 67;
cout << "Decimal equivalent is: " << dec << endl;
return 0;
}
int main()
{
string hex;
int decimal = 0, place = 0;
hex = "67";
int n = hex.length();
for (int i = n - 1; i >= 0; i--) {
int digit = hexToDecimal(hex[i]);
decimal += digit * pow(16, place);
place++;
}
return 0;
}
int main()
{
int decimal = 7;
return 0;
}
21. Write a Program for Decimal Octal Conversion
C++
int main()
{
int decimal, octal = 0, place = 1;
decimal = 55;
return 0;
}
int main()
{
int decimal = 103;
return 0;
}
int i = 0;
string octal = "";
while (1) {
// one by one extract from left, substring
// of size 3 and add its octal code
octal += bin_oct_map[bin.substr(i, 3)];
i += 3;
if (i == bin.size())
break;