Anyone help me to develop a program to compare two fractional numbers by overloading the relational operator.
static struct pll pll2_tbl[] = {
{ 42, 0, 1, 0 }, /* 806 MHz */
{ 53, 1, 3, 0 }, /* 1024 MHz */
{ 125, 0, 1, 1 }, /* 1200 MHz */
{ 73, 0, 1, 0 }, /* 1401 MHz */
};
and
static struct clkctl_acpu_speed acpu_freq_tbl[] = {
{ 0, 24576, LPXO, 0, 0, 30720000, 900, VDD_RAW(900) },
{ 0, 61440, PLL_3, 5, 11, 61440000, 900, VDD_RAW(900) },
{ 1, 122880, PLL_3, 5, 5, 61440000, 900, VDD_RAW(900) },
{ 0, 184320, PLL_3, 5, 4, 61440000, 900, VDD_RAW(900) },
{ 0, MAX_AXI_KHZ, AXI, 1, 0, 61440000, 900, VDD_RAW(900) },
{ 1, 245760, PLL_3, 5, 2, 61440000, 900, VDD_RAW(900) },
{ 1, 368640, PLL_3, 5, 1, 122800000, 900, VDD_RAW(900) },
/* AXI has MSMC1 implications. See above. */
{ 1, 768000, PLL_1, 2, 0, 153600000, 1050, VDD_RAW(1050) },
/*
* AXI has MSMC1 implications. See above.
*/
{ 1, 806400, PLL_2, 3, 0, UINT_MAX, 1100, VDD_RAW(1100), &pll2_tbl[0]},
{ 1, 1024000, PLL_2, 3, 0, UINT_MAX, 1200, VDD_RAW(1200), &pll2_tbl[1]},
{ 1, 1200000, PLL_2, 3, 0, UINT_MAX, 1200, VDD_RAW(1200), &pll2_tbl[2]},
{ 1, 1401600, PLL_2, 3, 0, UINT_MAX, 1250, VDD_RAW(1250), &pll2_tbl[3]},
{ 0 }
};
{78, 1, 3, 0 }, /* 1516 MHz */
{83, 1, 3, 0 }, /* 1612 MHz */
{88, 1, 3, 0 }, /* 1708 MHz */
and
{ 1, 1516800, PLL_2, 3, 0, UINT_MAX, 1250, VDD_RAW(1250), &pll2_tbl[6]},
{ 1, 1612800, PLL_2, 3, 0, UINT_MAX, 1275, VDD_RAW(1275), &pll2_tbl[7]},
{ 1, 1708800, PLL_2, 3, 0, UINT_MAX, 1300, VDD_RAW(1300), &pll2_tbl[8]},
{ 1, 1804800, PLL_2, 3, 0, UINT_MAX, 1325, VDD_RAW(1325), &pll2_tbl[9]},
{ 0 }
};
config CPU_FREQ_GOV_GOVNAMEHERE
tristate "'gov_name_lowercase' cpufreq governor"
depends on CPU_FREQ
help
governor' - a custom governor!
obj-$(CONFIG_CPU_FREQ_GOV_Governorname) += cpufreq_governorname.o
#btw check out the fact that we are adding .o file not .c, I will explain this later
#elif defined(CONFIG_CPU_FREQ_DEFAULT_GOV_Governorname)
extern struct cpufreq_governor cpufreq_gov_Governorname;
#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_Governorname)
config IOSCHED_SIO
tristate "Simple I/O scheduler"
default y
---help---
The Simple I/O scheduler is an extremely simple scheduler,
based on noop and deadline, that relies on deadlines to
ensure fairness. The algorithm does not do any sorting but
basic merging, trying to keep a minimum overhead. It is aimed
mainly for aleatory access devices (eg: flash devices).
obj-$(CONFIG_IOSCHED_SIO) += sio-iosched.o
For C :
#include<stdio.h>
For C++
#include<iostream.h>
int a;
char b;
float c;
or
int a=2;
char b = 's';
float c= 2.00
int a;
a= 'a';
int a=2;
int b=3;
float c;
float c= a+b; // compiler automatically converts value of a and b to int and calculates(Implicit)
---------------------------
float a = "10.00"; //float values
float b = "20.50";
int c;
c=(int)a+(int)b; //Explicit type casting
printf("%d",c);
--------------------------
char a= 'a';
int b = a; //implicit
or
int b = (int)a; //explicit
Note: Where implicit is required you can use explicit type casting as well to be safe...
-----------------------
now char a = '2';
int b= a - '0' //used to take number as character input and assign it to integer variable
Again you can write this as
int b = a;
or
int b = (int)a - '0'
For C
printf("Hello");
For C++
cout<< "Hello" ;
For Java
system.out.println("Hello");
For Python
print "Hello"
For bash
echo "Hello"
C
int a;
int b;
printf("Enter two numbers");
scanf("%d %d",&a,&b)
C++
int a;
int b;
cout << "Enter two numbers";
cin>>a;
cin>>b;
Java (A bit complex and thats why i wont include Java/python or even bash after this)
int a;
int b;
Scanner s=new Scanner(system.in);
System.out.println("Enter two numbers");
a=s.next();
b=s.next();
#include<stdio.h> // initializes the library for standard input/output
#include<conio.h> // Another header file containing command to clear the screen
void main() // for now just learn this,this is how you write the body of a C program,anything that you code inside is executed(no semi-colon here)
{ // Curly brackets are used to denote the start of your program body
int a; // variable initializing
int b; // variable initializing
clrscr(); // module to clear screen,not really required but i used it to show how conio.h is included to make this module work
printf("enter two numbers");
scanf("%d %d",&a,&b);
#now we need to store the value of the result somewhere,so we define new variables
int c,d,e,f;
#to add
c=a+b;
#to subtract
d=a-b;
#to divide
e=a/b;
#to multiply
f=a*b;
#Now to print the result
printf("the result is as follows %d,%d,%d,%d",c,d,e,f);
} # curly bracket to end the program
int a=20;
int b=10;
int c=a%b;
printf("%d",c); // would yield 0 as result
so wen coupled with if
if ( a%2 == 0 ) // Check next post to find out about if...:)
would check if number is even
if a is not even, then it would give a remainder wen divided by 2 and you can easily find out...
#include<stdio.h>
void main()
{
int i;
for (i=1;i<=50;i++) // see the contents of the loop in brackets ( i=0 >> stores the value 0 in i; i<=50 >> this is the actual condition,so as long as i's
{ value is less or equal to 50 the loop's body will run; i++ >> this increments the value by 1 every time the loop is executed
printf("dark wraith"); // the body of the loop is executed as long as the condition is satisfied
} // The curly bracket denotes the end of the loop
}
int i=0;
while(i<=50)
{
i++;
printf("dark wraith");
}
#include<stdio.h>
void main()
{
char a;
printf("Do you want to print a name(y/n");
scanf("%c",&a); // stores user input in char variable a
if(a ="y" ) // checks if whatever user entered is y
{
printf("dark wraith");
else if (a = "n") // additional condition to check if user inputs n
{
printf("no name"); // Note that the statement inside a loop body is terminated by semi-colon
}
else // if user enters anything apart from y/n then this is used
{
printf("enter a valid choice");
}
}
} // the three brackets here are one for the last else, one for the if and the last bracket is for closing void main
#include<stdio.h>
#include<stdlib.h> //header file for exit and break functions
void main()
{
int i;
printf("Press 1 to say Hi");
printf("Press 2 to say Hello");
printf("Press 3 to display XDA on screen");
printf("Press 4 to exit");
scanf("%d",&i)
switch( i )
{
case 1: //Executed if input is 1
printf("Hi");
break; // Break statement is used to skip the block and go to the next line after the entire switch case block.It is mandatory except the last default case (Though its better to include in that as well)
case 2:
printf("Hello");
break;
case 3 :
printf("XDA");
break;
case 4 :
exit(0);
default :
printf("make up your mind and try again..:P");
}
}
#!/bin/bash
echo "Press 1 to say Hi"
echo "Press 2 to say Hello"
echo "Press 3 to display XDA on screen"
echo "Press 4 to exit"
read input
case $input in
1)echo "Hi";; # A case ends with ;; not break
2)echo "Hello";;
3)echo "XDA";;
4)exit;;
#include<stdio.h>
void main()
{
char a[20]; // array definition
printf("Please enter your name");
scanf("%c",&a); // array is stored normally just like char or int using scanf
// Now to print the array
for(int i = 0 ; a[i] != '\0' ; i++)
// i= 0 and != means not equal to so the loop will go on till \0 in array i e the last character is not encountered
{
printf("%c",a[i]); // Prints array a[0] then a[1] and so on till a[] reached \0
}
}
#include<stdio.h>
void main()
{
char name[20];
printf("Enter a name");
scanf("%c",&name);
for( int i=0;a[i] !='\0' ; i++)
{
if(a[1] == 'a') // will check if second character i.e. position 2 has character a
// This is an example of nested if statement in for loop
{
printf("Yes");
}
else printf("no");
}
#include<stdio.h>
void add(int a,int b,int c) #We can use void here as we don't need return, we can just print the result from here
{
int c=a+b+c;
printf("%d",c);
}
void main()
{
int a,b,c;
a=2;
b=3;
c=4;
add(a,b,c);
// Now lets try one more thing
a=4;
b=5; // You can change values(Hence the name variable)..:P
c=7;
add(a,b,c);
}
typedef struct
{
char name[64],
char course[128],
int age,
int year,
}
student;
in main you can access it by
student s;
s.name;
Thanks! Not really for Android (sorry!), but you seriously helped me a lot in getting the hang of C! (Bonus: it's a lot like JavaScript, which I'm already pretty good at!)